package com.example.myapplication;
import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ExpandableListView;
import android.widget.ListView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends Activity {
    List<Integer> groupList;
    List<List<Integer>> itemList ;
    ListViewad il;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        info();
    }
    public void info(){
        ExpandableListView el = (ExpandableListView) findViewById(R.id.gd_test);
        el.setGroupIndicator(null);
        el.setDivider(null);
        initData();
        il = new ListViewad(MainActivity.this,groupList,itemList);
        el.setAdapter(il);
        for (int i = 0; i < il.getGroupCount();i++) {
            el.expandGroup(i);
        }

     el.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {

            @Override
            public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
                // TODO Auto-generated method stub
                return true;
            }
        });
    }
    private void initData() {
        if(groupList==null){
            groupList=new ArrayList<Integer>();
            itemList=new ArrayList<List<Integer>>();
        }else{
            groupList.clear();
            itemList.clear();
        }

             groupList.add(1);
             groupList.add(2);
             groupList.add(3);
             ArrayList<Integer> arr=new ArrayList<Integer>();
             arr.add(3);
             arr.add(2);
             ArrayList<Integer> arr2=new ArrayList<Integer>();
             arr2.add(3);
             arr2.add(3);
             arr2.add(3);
             arr2.add(1);
             itemList.add(arr);
             itemList.add(arr2);
             itemList.add(arr2);

    }





}